//
//  ViewController.swift
//  Guess
//
//  Created by stu on 2019/9/9.
//  Copyright © 2019年 Xiang HongFei. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var YouGuess: UIImageView!
    @IBOutlet weak var duolaGuess: UIImageView!
    @IBAction func guess(_ sender: UIButton) {
        duolaGuess.image = UIImage(named: "rock")
        
        let guess = arc4random_uniform(3)
        var say = ""
        
        if guess == 0 {
            say = "you loss"
            YouGuess.image = UIImage(named: "scissor")
        } else if guess == 1 {
            say = "打平"
            YouGuess.image = UIImage(named: "rock")
        } else {
            say = "you win"
            YouGuess.image = UIImage(named: "paper")
        }
        let alert = UIAlertController(title: "比赛结果", message: say, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "确定", style: .default, handler: {_ in
            self.duolaGuess.image = nil
            self.YouGuess.image = nil
        }))
        present(alert, animated: true, completion: nil)
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

